package com.peter.demo_02;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

/**
 * Hello world!
 *
 */
public class App {
	public static void main(String[] args) {
		try {
			String info = "https://v2.jinrishici.com/info";
			String doc1 = Jsoup.connect(info).timeout(1000000).ignoreContentType(true)
					.header("X-User-Token", "qEuk3pTNRgzX/pSnuKO7N2S1ovP3NsGq").execute().body();
			JsonObject returnData1 = new JsonParser().parse(doc1).getAsJsonObject();
			JsonObject jsonobj21 = returnData1.get("data").getAsJsonObject();
			String[] cotent21 = new Gson().fromJson(jsonobj21.get("tags").toString(), String[].class);
			String strs = "https://unsplash.com/search/photos/" + "小满";
			Document docs = Jsoup.connect(strs).timeout(1000000).get();
			Elements eles = docs.select(".yVU8k .IEpfq img");

			for (var a : eles) {
				String img_url = a.attr("src");
				System.out.println(img_url);
				System.out.println("----------------++++++++++++++++==---------------------------------");
			}

			String sentence = "https://v2.jinrishici.com/sentence";
			for (int i = 0; i < 3; i++) {
				String doc = Jsoup.connect(sentence).timeout(1000000).ignoreContentType(true)
						.header("X-User-Token", "qEuk3pTNRgzX/pSnuKO7N2S1ovP3NsGq").execute().body();
				JsonObject returnData = new JsonParser().parse(doc).getAsJsonObject();
				JsonObject jsonobj1 = returnData.get("data").getAsJsonObject();
				String tuijian = jsonobj1.get("content").getAsString();
				JsonObject jsonobj2 = jsonobj1.get("origin").getAsJsonObject();
				String title = jsonobj2.get("title").getAsString();
				String dynasty = jsonobj2.get("dynasty").getAsString();
				String author = jsonobj2.get("author").getAsString();
				JsonElement content = jsonobj2.get("content");
				String[] cotent = new Gson().fromJson(content.toString(), String[].class);
				System.out.println(cotent[0]);
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

class Demon {
	public static void main(String[] args) {
		String strs = "蒹葭苍苍，白露为霜。所谓伊人，在水一方。 溯洄从之，道阻且长。溯游从之，宛在水中央。 蒹葭萋萋，"
				+ "白露未晞。所谓伊人，在水之湄。 溯洄从之，道阻且跻。溯游从之，宛在水中坻。 蒹葭采采，白露未已。所谓伊人，在水之涘。 溯洄从之，道阻且右。溯游从之，宛在水中沚。";
		strs = strs.replaceAll("。", "").replaceAll("，", "");
		System.out.println(strs);
	}
}